<template>
  <div class="news">
    <h3>今日要闻，现在共有{{personList.length}}个人看新闻</h3>
    <button @click="handleClick">点我更新新闻</button>
    <ul>
      <li v-for="n in newsList" :key="n.id">{{n.title}}</li>
    </ul>
  </div>
</template>

<script>
  import { mapState } from 'vuex'

  export default {
    name:'News',
    computed: {
      ...mapState(['newsList','personList']),
    },
    methods: {
      handleClick(){
        this.$store.dispatch('getNews')
      }
    },
  }
</script>

<style scoped>
  .news {
    background-color: skyblue;
    padding: 10px;
  }
</style>